package com.pillpoppers.pillbox;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ContactListAdapter extends BaseAdapter{

	private ArrayList<String> Names;
	private ArrayList<String> Phone;
	private ArrayList<String> List;
	private LayoutInflater inflater;
	
	public ContactListAdapter(ContactsFragment contactsFragment, ArrayList<String> name, ArrayList<String> phone, ArrayList<String> list){
		this.Names = name;
		this.Phone = phone;
		this.List = list;
		
		inflater = (LayoutInflater) contactsFragment.getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	@Override
	public int getCount() {
		return Names.size();
	}
	
	
	public String getPhone(int position){
		return Phone.get(position);
	}
	
	public String getName(int position){
		return Names.get(position);
	}
	
	
	
	public String getId(int position){
		return List.get(position);
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = convertView;
		
		if (view == null) {
			view = inflater.inflate(R.layout.contact_list_view, null);
			
		}
		((TextView) view.findViewById(R.id.contact_name)).setText(Names.get(position));
		
		
		((TextView) view.findViewById(R.id.contact_number)).setText(Phone.get(position));
		
		return view;
	}

}
